import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
import { MetricsService } from './metrics.service';
import { CreateSystemMetricDto } from './dto/create-system-metric.dto';
import { CreatePerformanceMetricDto } from './dto/create-performance-metric.dto';
import { MetricsQueryDto } from './dto/metrics-query.dto';
import { TokenGuard } from '../../common/guards/token.guard';
import { RolesGuard } from '../../common/guards/roles.guard';
import { Roles } from '../../common/decorators/roles.decorator';

@Controller('metrics')
@UseGuards(TokenGuard, RolesGuard)
export class MetricsController {
  constructor(private readonly metricsService: MetricsService) {}

  @Post('system')
  @Roles('admin', 'devops')
  createSystemMetric(@Body() createSystemMetricDto: CreateSystemMetricDto) {
    return this.metricsService.createSystemMetric(createSystemMetricDto);
  }

  @Post('performance')
  @Roles('admin', 'devops')
  createPerformanceMetric(@Body() createPerformanceMetricDto: CreatePerformanceMetricDto) {
    return this.metricsService.createPerformanceMetric(createPerformanceMetricDto);
  }

  @Get('system')
  @Roles('admin', 'devops', 'viewer')
  getSystemMetrics(@Query() query: MetricsQueryDto) {
    return this.metricsService.getSystemMetrics(query);
  }

  @Get('performance')
  @Roles('admin', 'devops', 'viewer')
  getPerformanceMetrics(@Query() query: MetricsQueryDto) {
    return this.metricsService.getPerformanceMetrics(query);
  }
} 